1include <BOSL2/std.scad>
2
3// Shows all the orientations on cubes in their correct rotations.
4
5orientations = [
6 RIGHT, BACK, UP,
7 LEFT, FWD, DOWN,
8];
9axiscolors = ["red", "forestgreen", "dodgerblue"];
10axisdiam = 0.5;
11axislen = 12;
12axislbllen = 15;
13
14module orient_cube(ang) {
15 color("lightgray") cube(20, center=true);
16 color(axiscolors.x) up ((20-1)/2+0.01) back ((20-1)/2+0.01) cube([18,1,1], center=true);
17 color(axiscolors.y) up ((20-1)/2+0.01) right((20-1)/2+0.01) cube([1,18,1], center=true);
18 color(axiscolors.z) back((20-1)/2+0.01) right((20-1)/2+0.01) cube([1,1,18], center=true);
19 for (axis=[0:2], neg=[0:1]) {
20 idx = axis + 3*neg;
21 labels = [
22 "RIGHT", "BACK", "UP",
23 "LEFT", "FWD", "DOWN"
24 ];
25 rot(ang, from=UP, to=orientations[idx]) {
26 up(10) {
27 back(4) color("black") text3d(text=str("spin=",ang), size=2.5);
28 fwd(2) color(axiscolors[axis]) text3d(text="orient=", size=2.5);
29 fwd(6) color(axiscolors[axis]) text3d(text=labels[idx], size=2.5);
30 }
31 }
32 }
33}
34
35
36module text3d(text, h=0.01, size=3) {
37 linear_extrude(height=h, convexity=10) {
38 text(text=text, size=size, valign="center", halign="center");
39 }
40}
41
42module dottedline(l, d) for(y = [0:d*3:l]) up(y) sphere(d=d);
43
44module orient_cubes() {
45 // X axis
46 color(axiscolors[0]) {
47 yrot( 90) cylinder(h=axislen, d=axisdiam, center=false);
48 right(axislbllen) rot([90,0,0]) text3d(text="X+");
49 yrot(-90) dottedline(l=axislen, d=axisdiam);
50 left(axislbllen) rot([90,0,180]) text3d(text="X-");
51 }
52 // Y axis
53 color(axiscolors[1]) {
54 xrot(-90) cylinder(h=axislen, d=axisdiam, center=false);
55 back(axislbllen) rot([90,0,90]) text3d(text="Y+");
56 xrot( 90) dottedline(l=axislen, d=axisdiam);
57 fwd(axislbllen) rot([90,0,-90]) text3d(text="Y-");
58 }
59 // Z axis
60 color(axiscolors[2]) {
61 cylinder(h=axislen, d=axisdiam, center=false);
62 up(axislbllen) rot([0,-90,90+$vpr[2]]) text3d(text="Z+");
63 xrot(180) dottedline(l=axislen, d=axisdiam);
64 down(axislbllen) rot([0,90,-90+$vpr[2]]) text3d(text="Z-");
65 }
66
67 for (ang = [0:90:270]) {
68 off = rot(p=40*BACK,ang);
69 translate(off) {
70 orient_cube(ang);
71 }
72 }
73}
74
75
76orient_cubes();
77
78
79
80// vim: expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap